﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Order.ascx.cs" Inherits="ERP.Modules.Order" %>
<ext:Hidden ID="FormatTypeOrder" runat="server" />
<%--------------GridOrder-----------------%>
<ext:Panel ID="PanelOrder" runat="server" Layout="Fit" Border="False">
    <Content>
        <ext:GridPanel
            ID="grOrder"
            runat="server"
            Cls="grid-double"
            EnableColumnMove="true"
            Border="False">
            <Store>
                <ext:Store
                    ID="StoreOrder"
                    runat="server"
                    OnReadData="StoreOrder_RefreshData"
                    PageSize="20">
                    <Model>
                        <ext:Model runat="server" IDProperty="Order_Id" GroupField="Customer_Name">
                            <Fields>
                                <ext:ModelField Name="Rows_ID" Type="Int" />
                                <ext:ModelField Name="Order_Id" Type="Int" />
                                <ext:ModelField Name="Customer_Name" Type="String" />
                                <ext:ModelField Name="Order_Code" Type="String" />
                                <ext:ModelField Name="Order_DateBegin" Type="Date" />
                                <ext:ModelField Name="Order_DateEnd" Type="Date" />
                                <ext:ModelField Name="Order_Payment_Date" Type="Date" />
                                <ext:ModelField Name="IsActive" Type="Boolean" />
                            </Fields>
                        </ext:Model>
                    </Model>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:Column runat="server" Text="STT" Width="35" DataIndex="Rows_ID" Align="Center"></ext:Column>
                    <ext:Column runat="server" Text="ID" Width="15" DataIndex="Order_Id" Visible="false"></ext:Column>
                    <ext:Column runat="server" Text="Người đặt hàng" Width="200" DataIndex="Customer_Name"></ext:Column>
                    <ext:Column runat="server" Text="Chứng từ đặt" Width="100" DataIndex="Order_Code" Align="Left"></ext:Column>
                    <ext:DateColumn runat="server" Text="Ngày đặt" Width="100" DataIndex="Order_DateBegin" Format="dd-MM-yyyy" Align="Right" Flex="1"></ext:DateColumn>
                    <ext:DateColumn runat="server" Text="Ngày giao" Width="100" DataIndex="Order_DateEnd" Format="dd-MM-yyyy" Align="Right" Flex="1"></ext:DateColumn>
                    <ext:DateColumn runat="server" Text="Hạn thanh toán" Width="100" DataIndex="Order_Payment_Date" Format="dd-MM-yyyy" Align="Right" Flex="1"></ext:DateColumn>
                    <ext:CheckColumn runat="server" Text="Trạng thái" Width="75" DataIndex="IsActive" Align="Center"></ext:CheckColumn>
                </Columns>
            </ColumnModel>
            <Features>
                <ext:Grouping
                    runat="server" 
                    HideGroupedHeader="true"
                    GroupByText="Xem theo phân nhóm"
                    ShowGroupsText="Phân nhóm"
                    GroupHeaderTplString="{name} ({rows.length} danh mục con {[values.rows.length > 1 ? '' : '']})"
                    StartCollapsed="True" />
            </Features>
            <DirectEvents>
                <ItemDblClick OnEvent="OrderDblClick">
                    <ExtraParams>
                        <ext:Parameter Name="Order_Id" Value="record.data.Order_Id" Mode="Raw" />
                    </ExtraParams>
                    <EventMask ShowMask="true" Msg="Đang tải..." />
                </ItemDblClick>
            </DirectEvents>
            <SelectionModel>
                <ext:CheckboxSelectionModel runat="server" Mode="Multi">
                    <Listeners>
                        <SelectionChange Handler="
                            if (selected.length == 0) {
                                #{btnEdit}.disable();
                                #{btnDel}.disable();
                                #{btnReview}.disable();
                            } else {
                                #{btnEdit}.enable();
                                #{btnDel}.enable();
                                #{btnReview}.enable();
                            }" />
                    </Listeners>
                </ext:CheckboxSelectionModel>
            </SelectionModel>
            <View>
                <ext:GridView runat="server" StripeRows="true" />
            </View>
            <DockedItems>
                <ext:Toolbar runat="server" Dock="Top">
                    <Items>
                        <ext:Button ID="btnAddNew" runat="server" Text="Thêm mới" Icon="ApplicationAdd">
                            <DirectEvents>
                                <Click OnEvent="btnAddNew_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button ID="btnEdit" runat="server" Text="Sửa" Icon="ApplicationEdit">
                            <DirectEvents>
                                <Click OnEvent="btnEdit_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button ID="btnDel" runat="server" Text="Xoá" Icon="ApplicationDelete">
                            <DirectEvents>
                                <Click OnEvent="btnDel_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                    <ExtraParams>
                                        <ext:Parameter Name="name" Value="btnDel"></ext:Parameter>
                                    </ExtraParams>
                                    <Confirmation ConfirmRequest="true"
                                        Title="Thông Báo" Message="Bạn có muốn xoá mẫu tin này không ?">
                                    </Confirmation>
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button ID="btnReview" runat="server" Text="Xét duyệt" Icon="Tick" ToolTip="Check vào một phiếu đề nghị để xét duyệt">
                            <DirectEvents>
                                <Click OnEvent="btnReview_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button ID="btnExport" runat="server" Text="Xuất tập tin" Icon="Printer">
                            <Menu>
                                <ext:Menu ID="MenuMain" runat="server">
                                    <Items>
                                        <ext:MenuItem ID="MenuItemExportXML" runat="server" Text="XML" Icon="PageCode">
                                            <Listeners>
                                                <Click Handler="submitValue(#{grOrder}, #{FormatTypeOrder}, 'xml');" />
                                            </Listeners>
                                        </ext:MenuItem>
                                    </Items>
                                </ext:Menu>
                            </Menu>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:DateField ID="txtDateBeginFillter" EmptyText="Từ ngày" runat="server" MarginSpec="0 8 0 0"/>
                        <ext:DateField ID="txtDateEndFillter" EmptyText="Đến ngày" runat="server" MarginSpec="0 5 0 0"/>
                        <ext:Button ID="btnFillter" runat="server" Text="Lọc" Icon="ApplicationGo" ToolTip="Chọn lọc theo ngày đặt hàng">
                            <DirectEvents>
                                <Click OnEvent="btnFillter_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:SelectBox
                            ID="SelectBoxReview"
                            runat="server"
                            Cls="x-select-box"
                            MarginSpec="0 8 0 0"
                            EmptyText="Chọn trạng thái">
                            <Items>
                                <ext:ListItem Value="1" Text="Đã duyệt"/>
                                <ext:ListItem Value="0" Text="Chưa duyệt"/>
                            </Items>
                            <DirectEvents>
                                <Select OnEvent="SelectBoxReview_Change">
                                    <EventMask ShowMask="true" Msg="Đang tải..."></EventMask>
                                </Select>
                            </DirectEvents>
                        </ext:SelectBox>
                        <ext:ToolbarSeparator />
                        <ext:SelectBox
                            ID="SelectBoxIsUsed"
                            runat="server"
                            Cls="x-select-box"
                            MarginSpec="0 8 0 0"
                            EmptyText="Chọn trạng thái sử dụng">
                            <Items>
                                <ext:ListItem Value="1" Text="Đã sử dụng"/>
                                <ext:ListItem Value="0" Text="Chưa sử dụng"/>
                            </Items>
                            <DirectEvents>
                                <Select OnEvent="SelectBoxIsUsed_Change">
                                    <EventMask ShowMask="true" Msg="Đang tải..."></EventMask>
                                </Select>
                            </DirectEvents>
                        </ext:SelectBox>
                    </Items>
                </ext:Toolbar>
                <ext:Toolbar runat="server" Dock="Bottom" AnchorHorizontal="100%">
                    <Items>
                        <ext:TriggerField ID="txtSearch" runat="server" Width="200" EnableKeyEvents="true" MarginSpec="0 8 0 0">
                            <Triggers>
                                <ext:FieldTrigger Icon="Search" />
                            </Triggers>
                            <DirectEvents>
                                <TriggerClick OnEvent="Search_Event">
                                        <EventMask ShowMask="true" Msg="Đang tải..." />
                                </TriggerClick>
                                <SpecialKey OnEvent="Search_Event" Before="return e.getKey() == Ext.EventObject.ENTER;">
                                        <EventMask ShowMask="true" Msg="Đang tải..." />
                                </SpecialKey>
                            </DirectEvents>
                        </ext:TriggerField>
                        <ext:PagingToolbar ID="PagingToolbar1" runat="server" StoreID="StoreOrder" BeforePageText="Trang" AfterPageText="của {0}" LastText="Cuối" NextText="Kế tiếp" PrevText="Trở lại" FirstText="Đầu" RefreshText="Làm tươi" DisplayInfo="true" DisplayMsg="Trang {0} - {1} của {2}" />
                    </Items>
                </ext:Toolbar>
            </DockedItems>
        </ext:GridPanel>
    </Content>
</ext:Panel>
<ext:Panel ID="PanelMainOrder" runat="server">
    <Content>
        <%-----------WindowsOrderOrder-----------------%>
        <ext:Window ID="WindowsOrder" runat="server"
            Title="Cập nhật đơn mua hàng"
            Width="975"
            Height="583"
            Hidden="True"
            Region="Center"
            Modal="True"
            HideMode="Display"
            Border="False"
            Padding="5"
            DefaultButton="btnSavePopUp"
            Resizable="True">
            <Items>
                <ext:Toolbar runat="server">
                    <Items>
                        <ext:Button runat="server" Text="Lưu lại" Icon="Disk" ID="btnSavePopUp">
                            <DirectEvents>
                                <Click OnEvent="btnSavePopUp_Click" Before="return #{FormPanelOrder}.isValid();">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button runat="server" Text="Thêm vật tư" Icon="Add" ID="btnAddMaterial" MarginSpec="0 8 0 0">
                            <DirectEvents>
                                <Click OnEvent="btnAddMaterial_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button runat="server" Text="Xoá vật tư" Icon="Cancel" ID="btnDelMaterial" MarginSpec="0 8 0 0">
                            <DirectEvents>
                                <Click OnEvent="btnDelMaterial_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                    <ExtraParams>
                                        <ext:Parameter Name="name" Value="btnDel"></ext:Parameter>
                                    </ExtraParams>
                                    <Confirmation ConfirmRequest="true"
                                        Title="Thông Báo" Message="Bạn có muốn xoá vật tư này không ?">
                                    </Confirmation>
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button runat="server" Text="Huỷ bỏ" Icon="Decline" ID="btnCancelPopUp">
                            <DirectEvents>
                                <Click OnEvent="btnCancelPopUp_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:TextField ID="txtOrder_ID" runat="server" FieldLabel="ID" LabelAlign="Right" Hidden="true" />
                    </Items>
                </ext:Toolbar>
                <ext:Panel
                    runat="server" 
                    Layout="ColumnLayout">
                        <Items>
                            <ext:Panel
                            runat="server" 
                            Width="218"
                            Frame="True"
                            MarginSpec="0 5 0 0"
                            Height="520">
                            <Items>
                                <ext:FormPanel ID="FormPanelOrder" runat="server"
                                    AutoHeight="true"
                                    BodyPadding="4"
                                    Frame="true"
                                    DefaultAnchor="100%">
                                    <Items>
                                        <ext:Label runat="server" LabelWidth="83" LabelAlign="Top" Text="Mã đơn hàng" />
                                        <ext:FieldContainer
                                                runat="server"
                                                AnchorHorizontal="100%"
                                                Layout="HBoxLayout">
                                                <Items>
                                                    <ext:TextField ID="txtOrderCode" runat="server" AllowBlank="False" Width="165" Margins="8 3 0 0" />
                                                    <ext:Button runat="server" Text="" Icon="Reload" ID="btnRefreshOrderCode" ToolTip="Click vào để tải lại mã" Margins="8 3 0 0">
                                                        <DirectEvents>
                                                            <Click OnEvent="btnRefreshOrderCode_Click">
                                                                <EventMask ShowMask="true" Msg="Đang tải..." />
                                                            </Click>
                                                        </DirectEvents>
                                                    </ext:Button>
                                                </Items>
                                            </ext:FieldContainer>
                                        <ext:Label runat="server" LabelWidth="83" LabelAlign="Top" Text="Ngày lập HĐ" Margins="8 3 0 0" />
                                        <ext:DateField ID="txtDateBegin" runat="server" AllowBlank="False" Width="250" MarginSpec="8 3 5 0" />
                                        <ext:Label runat="server" LabelWidth="83" LabelAlign="Top" Text="Ngày đặt" Margins="8 3 0 0" />
                                        <ext:DateField ID="txtDateBeginPay" runat="server" AllowBlank="True" Width="250" MarginSpec="8 3 5 0" />
                                        <ext:Label runat="server" LabelWidth="83" LabelAlign="Top" Text="Ngày giao" Margins="8 3 0 0" />
                                        <ext:DateField ID="txtDateEndPay" runat="server" AllowBlank="True" Width="250" MarginSpec="8 3 5 0" />
                                        <ext:Label runat="server" LabelWidth="83" LabelAlign="Top" Text="Hạn thanh toán" Margins="8 3 0 0" />
                                        <ext:DateField ID="txtPaymentDate" runat="server" AllowBlank="True" Width="250" MarginSpec="8 3 5 0" />
                                        <ext:Label runat="server" LabelWidth="83" LabelAlign="Top" Text="Mã nhà cung cấp" MarginSpec="8 3 8 0" />
                                        <ext:TextField ID="txtCustomerAlias" ReadOnly="True" AllowBlank="False" runat="server" Width="250" MarginSpec="8 3 8 0" />
                                        <ext:Label runat="server" LabelWidth="83" LabelAlign="Top" Text="Tên nhà cung cấp" MarginSpec="8 3 8 0" />
                                        <ext:FieldContainer
                                            runat="server"
                                            AnchorHorizontal="100%"
                                            Layout="HBoxLayout">
                                            <Items>
                                                <ext:TextField ID="txtCustomerName" ReadOnly="True" Width="162" AllowBlank="False" runat="server" MarginSpec="8 3 0 0" />
                                                <ext:Button runat="server" Text="" Icon="BulletGet" ID="btnAddCustomer" ToolTip="Đến danh sách" MarginSpec="8 3 0 0">
                                                        <DirectEvents>
                                                        <Click OnEvent="btnAddCustomer_Click">
                                                            <EventMask ShowMask="true" Msg="Đang tải..." />
                                                        </Click>
                                                    </DirectEvents>
                                                </ext:Button>
                                                <ext:Hidden runat="server" ID="txtCustomerID" AllowBlank="False"></ext:Hidden>
                                            </Items>
                                        </ext:FieldContainer>
                                        <ext:Label runat="server" LabelWidth="83" LabelAlign="Top" Text="Mã số thuế" Margins="0 3 8 0" />
                                        <ext:TextField ID="txtTaxCode" runat="server" AnchorHorizontal="100%" ReadOnly="True" MarginSpec="5 0 0 0" />
                                        <ext:Label runat="server" LabelWidth="83" LabelAlign="Top" Text="Địa chỉ" MarginSpec="0 3 8 0" />
                                        <ext:TextField ID="txtCustomerAddress" ReadOnly="True" runat="server" AnchorHorizontal="100%" MarginSpec="5 0 0 0" />
                                        <ext:Label runat="server" LabelWidth="83" LabelAlign="Top" Text="Ghi chú" MarginSpec="0 3 8 0" />
                                        <ext:TextArea ID="txtDescription" runat="server" AnchorHorizontal="100%" Height="30" MarginSpec="5 0 0 0"/>
                                    </Items>
                                </ext:FormPanel>
                            </Items>
                            </ext:Panel>
                            <ext:Panel
                            runat="server" 
                            Width="736"
                            Layout="Fit" 
                            Border="False"
                            Height="455">
                                <Items>
                                    <ext:GridPanel
                                    ID="grOrder_Detail"
                                    Cls="grid-double"
                                    runat="server"
                                    EnableColumnMove="true"
                                    AutoWidth="true"
                                    AutoScroll="true"
                                    Layout="Fit"
                                    Height="195">
                                    <Store>
                                        <ext:Store
                                            ID="StoreOrder_Detail"
                                            runat="server"
                                            OnReadData="StoreOrder_Detail_RefreshData">
                                            <Model>
                                                <ext:Model runat="server" IDProperty="Order_Detail_Id">
                                                    <Fields>
                                                        <ext:ModelField Name="Order_Id" Type="Int" />
                                                        <ext:ModelField Name="Materials_Id" Type="Int" />
                                                        <ext:ModelField Name="Materials_Alias" Type="String" />
                                                        <ext:ModelField Name="Materials_Name" Type="String" />
                                                        <ext:ModelField Name="Unit_Name" Type="String" />
                                                        <ext:ModelField Name="Order_Detail_Quality" Type="Int" />
                                                        <ext:ModelField Name="Order_Detail_Price" Type="Float" />
                                                        <ext:ModelField Name="Price_Initially" Type="Float" />
                                                        <ext:ModelField Name="Order_Detail_CK_Percent" Type="Float" />
                                                        <ext:ModelField Name="Order_Detail_CK" Type="Float" />
                                                        <ext:ModelField Name="Order_Detail_VAT_Percent" Type="Float" />
                                                        <ext:ModelField Name="Order_Detail_VAT" Type="Float" />
                                                        <ext:ModelField Name="Order_Detail_Total_Price" Type="Float" />
                                                    </Fields>
                                                </ext:Model>
                                            </Model>
                                        </ext:Store>
                                    </Store>
                                    <ColumnModel runat="server">
                                        <Columns>
                                            <ext:RowNumbererColumn Text="STT" runat="server" Width="30" Align="Center" />
                                            <ext:Column runat="server" Text="Mã hàng" Width="100" DataIndex="Materials_Alias" />
                                            <ext:Column runat="server" Text="Tên hàng" Width="100" DataIndex="Materials_Name" />
                                            <ext:Column runat="server" Text="Đơn vị tính" Width="90" DataIndex="Unit_Name" />
                                            <ext:Column runat="server" Text="SL đề nghị" Width="90" DataIndex="Order_Detail_Quality">
                                                <Editor>
                                                    <ext:NumberField runat="server" MinValue="0">
                                                    </ext:NumberField>
                                                </Editor>
                                            </ext:Column>
                                            <ext:Column runat="server" AllowBlank="false" MinValue="0" Text="Đơn giá" Width="100" DataIndex="Order_Detail_Price">
                                                    <Editor>
                                                    <ext:NumberField runat="server" MinValue="0">
                                                    </ext:NumberField>
                                                </Editor>
                                                <Renderer Fn="Ext.util.Format.numberRenderer('0,000')" />
                                            </ext:Column>
                                            <ext:NumberColumn runat="server" Text="Tiền CK" Width="90" DataIndex="Order_Detail_CK" Format="0,00" />
                                            <ext:Column runat="server" Text="CK %" Width="90" DataIndex="Order_Detail_CK_Percent">
                                               <Editor>
                                                    <ext:NumberField runat="server" MinValue="0">
                                                    </ext:NumberField>
                                                </Editor>
                                            </ext:Column>
                                            <ext:NumberColumn runat="server" Text="Tiền VAT" Width="90" DataIndex="Order_Detail_VAT" Format="0,00" />
                                            <ext:Column runat="server" Text="VAT %" Width="90" DataIndex="Order_Detail_VAT_Percent">
                                                <Editor>
                                                    <ext:NumberField runat="server" MinValue="0">
                                                    </ext:NumberField>
                                                </Editor>
                                            </ext:Column>
                                            <ext:NumberColumn runat="server" Text="Thành tiền" Width="90" DataIndex="Order_Detail_Total_Price" Format="0,00" /> 
                                        </Columns>
                                    </ColumnModel>
                                    <Plugins>
                                        <ext:RowEditing runat="server" SaveBtnText="Cập nhật" CancelBtnText="Hủy bỏ">
                                            <DirectEvents>
                                                <Edit OnEvent="UpdateMaterials_Click">
                                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                                    <ExtraParams>
                                                        <ext:Parameter Name="grOrder_Detail" Value="Ext.encode(#{grOrder_Detail}.getRowsValues({selectedOnly : true}))" Mode="Raw" />
                                                    </ExtraParams>
                                                </Edit>
                                            </DirectEvents>
                                        </ext:RowEditing>
                                    </Plugins>
                                    <SelectionModel>
                                        <ext:CheckboxSelectionModel runat="server" Mode="Multi" />
                                    </SelectionModel>
                                    <DockedItems>
                                        <ext:Toolbar runat="server" Dock="Bottom" AnchorHorizontal="100%">
                                            <Items>
                                                <ext:PagingToolbar runat="server" StoreID="StoreOrder_Detail" EmptyMsg="Không có dữ liệu" BeforePageText="Trang" AfterPageText="của {0}" LastText="Cuối" NextText="Kế tiếp" PrevText="Trở lại" FirstText="Đầu" RefreshText="Làm tươi" DisplayInfo="true" DisplayMsg="Trang {0} - {1} của {2}" />
                                            </Items>
                                        </ext:Toolbar>
                                    </DockedItems>
                                </ext:GridPanel>
                                </Items>
                            </ext:Panel>
                            <ext:Panel
                            runat="server" 
                            Width="736"
                            MarginSpec="5 0 0 0"
                            Border="True"
                            Frame="True"
                            Height="56">
                                <Items>
                                    <ext:FieldContainer
                                    runat="server"
                                    AnchorHorizontal="100%">
                                    <Items>
                                        <ext:Label runat="server" Text="Tổng số lượng vật tư:" MarginSpec="0 8 8 0"></ext:Label>
                                        <ext:Label ID="lbQualityWithOrder" Cls="x-label-right-cost" runat="server" Text="0" Width="80"></ext:Label>

                                        <ext:Label runat="server" Text="Tổng đơn giá:" MarginSpec="0 8 8 0"></ext:Label>
                                        <ext:Label ID="lbPriceWithOrder" Cls="x-label-right-cost" runat="server" Text="0" Width="80"></ext:Label>

                                        <ext:Label runat="server" Text="Tổng tiền CK:" MarginSpec="0 8 8 0"></ext:Label>
                                        <ext:Label ID="lbPriCKWithOrder_Total" Cls="x-label-right-cost" runat="server" Text="0" Width="80"></ext:Label>

                                        <ext:Label runat="server" Text="Tổng tiền VAT:" MarginSpec="0 8 8 0"></ext:Label>
                                        <ext:Label ID="lbPriVATWithOrder" Cls="x-label-right-cost" runat="server" Text="0" Width="80"></ext:Label>
                                    </Items>
                                </ext:FieldContainer>
                                    <ext:FieldContainer
                                    runat="server"
                                    AnchorHorizontal="100%">
                                    <Items>
                                        <ext:Label runat="server" Text="Tổng tiền các mặt hàng bao gồm CK và VAT:" MarginSpec="0 8 8 0"></ext:Label>
                                        <ext:Label ID="lbTotalCostOrderWithOrder" Cls="x-label-right-cost" runat="server" Text="0"></ext:Label>
                                    </Items>
                                </ext:FieldContainer>
                                </Items>
                            </ext:Panel>
                        </Items>
                    </ext:Panel>
            </Items>
        </ext:Window>
        <%--------------Material-----------------%>
        <ext:Window ID="WindowMaterial" runat="server"
            Title="Thông tin vật tư"
            DefaultAnchor="100%"
            Width="829"
            Height="400"
            Hidden="true"
            AutoScroll="false"
            Maximizable="False"
            Minimizable="False"
            AutoDataBind="true"
            Region="Center"
            Resizable="False"
            Modal="true"
            Layout="Fit"
            HideMode="Offsets"
            Constrain="True">
            <Content>
                <ext:GridPanel
                    ID="grMaterial"
                    Border="True"
                    runat="server"
                    AutoWidth="true"
                    AutoScroll="true"
                    Cls="gird"
                    EnableColumnMove="true">
                    <Store>
                        <ext:Store
                            ID="StoreMaterial"
                            runat="server"
                            OnReadData="StoreMaterial_RefreshData"
                            PageSize="10">
                            <Model>
                                <ext:Model runat="server" IDProperty="Materials_Id">
                                    <Fields>
                                        <ext:ModelField Name="Rows_ID" Type="Int" />
                                        <ext:ModelField Name="Materials_Alias" Type="String" />
                                        <ext:ModelField Name="Materials_Name" Type="String" />
                                        <ext:ModelField Name="Materials_Type_Name" Type="String" />
                                        <ext:ModelField Name="Unit_Name" Type="String" />
                                    </Fields>
                                </ext:Model>
                            </Model>
                        </ext:Store>
                    </Store>
                    <ColumnModel runat="server">
                        <Columns>
                            <ext:RowNumbererColumn runat="server" Width="30" Align="Center" />
                            <ext:Column runat="server" Text="ID" Width="15" DataIndex="Materials_Id" Visible="false"></ext:Column>
                            <ext:Column runat="server" Text="Mã vật tư" Width="100" DataIndex="Materials_Alias" Align="Left"></ext:Column>
                            <ext:Column runat="server" Text="Tên vật tư" Width="200" DataIndex="Materials_Name" Align="Left"></ext:Column>
                            <ext:Column runat="server" Text="Loại vật tư" Width="200" DataIndex="Materials_Type_Name" Align="Left"></ext:Column>
                            <ext:Column runat="server" Text="Đơn vị tính" Width="200" DataIndex="Unit_Name" Align="Center" Flex="1"></ext:Column>
                        </Columns>
                    </ColumnModel>
                    <SelectionModel>
                        <ext:CheckboxSelectionModel runat="server" Mode="Multi" />
                    </SelectionModel>
                    <TopBar>
                        <ext:Toolbar runat="server">
                            <Items>
                                <ext:Button ID="btnSelectMaterial" runat="server" Text="Chọn vật tư" Icon="Accept" ToolTip="Chọn vật tư">
                                    <DirectEvents>
                                        <Click OnEvent="btnSelectMaterial_Click">
                                            <EventMask ShowMask="true" Msg="Đang tải..." />
                                        </Click>
                                    </DirectEvents>
                                </ext:Button>
                            </Items>
                        </ext:Toolbar>
                    </TopBar>
                    <DockedItems>
                        <ext:Toolbar runat="server" Dock="Bottom" AnchorHorizontal="100%">
                            <Items>
                                <ext:PagingToolbar runat="server" StoreID="StoreMaterial" BeforePageText="Trang" AfterPageText="của {0}" LastText="Cuối" NextText="Kế tiếp" PrevText="Trở lại" FirstText="Đầu" RefreshText="Làm tươi" DisplayInfo="true" DisplayMsg="Trang {0} - {1} của {2}" />
                            </Items>
                        </ext:Toolbar>
                    </DockedItems>
                </ext:GridPanel>
            </Content>
        </ext:Window>
        <%--------------Customer-----------------%>
        <ext:Window ID="WindowCustomerOrder" runat="server"
            Title="Thông tin khách hàng"
            DefaultAnchor="100%"
            Width="829"
            Height="400"
            Hidden="true"
            AutoScroll="false"
            Maximizable="False"
            Minimizable="False"
            AutoDataBind="true"
            Region="Center"
            Resizable="False"
            Modal="true"
            Layout="Fit"
            HideMode="Offsets"
            Constrain="True">
            <Content>
                <ext:GridPanel
                    ID="grCustomerOrder"
                    Border="True"
                    runat="server"
                    AutoWidth="true"
                    AutoScroll="true"
                    Cls="gird"
                    EnableColumnMove="true">
                    <Store>
                        <ext:Store
                            ID="StoreCustomerOrder"
                            runat="server"
                            OnReadData="StoreCustomerOrder_RefreshData"
                            PageSize="14">
                            <Model>
                                <ext:Model runat="server" IDProperty="Customer_ID">
                                    <Fields>
                                        <ext:ModelField Name="Customer_ID" Type="Int" />
                                        <ext:ModelField Name="Customer_Alias" Type="String" />
                                        <ext:ModelField Name="Customer_Name" Type="String" />
                                    </Fields>
                                </ext:Model>
                            </Model>
                        </ext:Store>
                    </Store>
                    <ColumnModel runat="server">
                        <Columns>
                            <ext:RowNumbererColumn runat="server" Width="30" Align="Center" />
                            <ext:Column runat="server" Text="Mã khách hàng" Width="100" DataIndex="Customer_Alias" Align="Left"></ext:Column>
                            <ext:Column runat="server" Text="Tên khách hàng" Width="100" DataIndex="Customer_Name" Align="Left" Flex="1"></ext:Column>
                        </Columns>
                    </ColumnModel>
                    <SelectionModel>
                        <ext:CellSelectionModel runat="server">
                            <DirectEvents>
                                <Select OnEvent="CellOrderCustomer_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Select>
                            </DirectEvents>
                        </ext:CellSelectionModel>
                    </SelectionModel>
                    <DockedItems>
                        <ext:Toolbar runat="server" Dock="Bottom" AnchorHorizontal="100%">
                            <Items>
                                <ext:PagingToolbar runat="server" StoreID="StoreCustomerOrder" BeforePageText="Trang" AfterPageText="của {0}" LastText="Cuối" NextText="Kế tiếp" PrevText="Trở lại" FirstText="Đầu" RefreshText="Làm tươi" DisplayInfo="true" DisplayMsg="Trang {0} - {1} của {2}" />
                            </Items>
                        </ext:Toolbar>
                    </DockedItems>
                </ext:GridPanel>
            </Content>
        </ext:Window>
        <%----------------WindowsOrderReview-----------------%>
        <ext:Window ID="WindowOrderReview" runat="server"
            Title="Xét duyệt đơn mua hàng"
            Width="975"
            Height="583"
            Hidden="True"
            Region="Center"
            Modal="True"
            HideMode="Display"
            Border="False"
            Padding="5"
            DefaultButton="btnSavePopUp"
            Resizable="True">
            <Items>
                <ext:Toolbar runat="server">
                    <Items>
                        <ext:Button ID="btnReviewWindow" runat="server" Text="Xét duyệt" Icon="Tick" ToolTip="Xét duyệt mẫu tin">
                            <DirectEvents>
                                <Click OnEvent="btnReviewWindow_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                    <Confirmation ConfirmRequest="true"
                                                    Title="Thông Báo" Message="Bạn có muốn xét duyệt đơn đặt hàng này không ?">
                                    </Confirmation>
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button ID="btnUnReviewWindow" runat="server" Text="Bỏ xét duyệt" Icon="Cross" ToolTip="Huỷ xét duyệt mẫu tin">
                            <DirectEvents>
                                <Click OnEvent="btnUnReviewWindow_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                    <Confirmation ConfirmRequest="true"
                                                    Title="Thông Báo" Message="Bạn có muốn huỷ xét duyệt đơn đặt hàng này không ?">
                                    </Confirmation>
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button ID="btnReLoadReviewOrder" runat="server" Text="Làm tươi" Icon="Reload" ToolTip="Làm tươi">
                            <DirectEvents>
                                <Click OnEvent="btnReLoadReviewOrder_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button ID="btnPrintReviewOrder" runat="server" Text="In đơn mua hàng" Icon="Printer" ToolTip="In đơn mua hàng" OnClientClick=" window.print(); "></ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button ID="btnExitReviewOrder" runat="server" Text="Đóng lại" Icon="Cancel" ToolTip="Đóng cửa sổ xét duyệt">
                            <DirectEvents>
                                <Click OnEvent="btnExitReviewOrder_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:TextField runat="server" ID="txtIDReview" Hidden="True"></ext:TextField>
                    </Items>
                </ext:Toolbar>
                <ext:Panel
                    runat="server" 
                    Layout="ColumnLayout">
                        <Items>
                            <ext:Panel
                            runat="server" 
                            Width="218"
                            Frame="True"
                            MarginSpec="0 5 0 0"
                            Height="520">
                            <Items>
                                <ext:FormPanel runat="server"
                                    AutoHeight="true"
                                    BodyPadding="4"
                                    Cls="form-panel"
                                    Frame="true"
                                    DefaultAnchor="100%">
                                    <Items>
                                        <ext:Label runat="server" AnchorHorizontal="100%" LabelAlign="Top" Text="Mã đơn hàng" />
                                        <ext:TextField ID="lbReviewOrderCode" ReadOnly="True" FieldCls="textboxreview" LabelAlign="Top" AnchorHorizontal="100%" runat="server" Text="" MarginSpec="8 3 5 0"/>
                                        <ext:Label runat="server" AnchorHorizontal="100%" LabelAlign="Top" Text="Ngày lập HĐ" Margins="8 3 0 0" />
                                        <ext:TextField ID="lbReviewOrderDate" ReadOnly="True" FieldCls="textboxreview" AnchorHorizontal="100%" runat="server" Text="" MarginSpec="8 3 5 0"/>
                                        <ext:Label runat="server" AnchorHorizontal="100%" LabelAlign="Top" Text="Mã nhà cung cấp" MarginSpec="8 3 8 0" />
                                        <ext:TextField ID="lbReviewCustomer_Alias" ReadOnly="True" FieldCls="textboxreview" AnchorHorizontal="100%" runat="server" Text="" MarginSpec="8 3 5 0"/>
                                        <ext:Label runat="server" AnchorHorizontal="100%" LabelAlign="Top" Text="Tên nhà cung cấp" MarginSpec="8 3 8 0" />
                                        <ext:TextField ID="lbReviewCustomer_Name" ReadOnly="True" FieldCls="textboxreview" AnchorHorizontal="100%" runat="server" Text="" MarginSpec="8 3 5 0"/>
                                        <ext:Label runat="server" AnchorHorizontal="100%" LabelAlign="Top" Text="Ngày duyệt/huỷ:" />
                                        <ext:TextField ID="lbReviewDateUpdate" ReadOnly="True" FieldCls="textboxreview" runat="server" Text="" MarginSpec="8 3 5 0"/>
                                        <ext:Label runat="server" AnchorHorizontal="100%" LabelAlign="Top" Text="Thời gian duyệt/huỷ vào lúc:" />
                                        <ext:TextField ID="lbReViewTime" ReadOnly="True" FieldCls="textboxreview" AnchorHorizontal="100%" runat="server" Text="" MarginSpec="8 3 5 0"/>
                                    </Items>
                                </ext:FormPanel>
                            </Items>
                            </ext:Panel>
                            <ext:Panel
                            runat="server" 
                            Width="736"
                            Layout="Fit" 
                            Border="False"
                            Height="455">
                                <Items>
                                    <ext:GridPanel
                                    ID="grOrderReview"
                                    Cls="grid-double"
                                    runat="server"
                                    EnableColumnMove="true"
                                    AutoWidth="true"
                                    AutoScroll="true"
                                    Layout="Fit"
                                    Height="195">
                                    <Store>
                                        <ext:Store
                                            ID="StoreOrderReview"
                                            runat="server"
                                            OnReadData="StoreOrderReview_RefreshData">
                                            <Model>
                                                <ext:Model runat="server" IDProperty="Order_Detail_Id">
                                                    <Fields>
                                                        <ext:ModelField Name="Order_Id" Type="Int" />
                                                        <ext:ModelField Name="Materials_Id" Type="Int" />
                                                        <ext:ModelField Name="Materials_Alias" Type="String" />
                                                        <ext:ModelField Name="Materials_Name" Type="String" />
                                                        <ext:ModelField Name="Unit_Name" Type="String" />
                                                        <ext:ModelField Name="Order_Detail_Quality" Type="Int" />
                                                        <ext:ModelField Name="Order_Detail_Price" Type="Float" />
                                                        <ext:ModelField Name="Price_Initially" Type="Float" />
                                                        <ext:ModelField Name="Order_Detail_CK_Percent" Type="Float" />
                                                        <ext:ModelField Name="Order_Detail_CK" Type="Float" />
                                                        <ext:ModelField Name="Order_Detail_VAT_Percent" Type="Float" />
                                                        <ext:ModelField Name="Order_Detail_VAT" Type="Float" />
                                                        <ext:ModelField Name="Order_Detail_Total_Price" Type="Float" />
                                                    </Fields>
                                                </ext:Model>
                                            </Model>
                                        </ext:Store>
                                    </Store>
                                    <ColumnModel runat="server">
                                        <Columns>
                                            <ext:RowNumbererColumn Text="STT" runat="server" Width="30" Align="Center" />
                                            <ext:Column runat="server" Text="Mã hàng" Width="100" DataIndex="Materials_Alias" />
                                            <ext:Column runat="server" Text="Tên hàng" Width="100" DataIndex="Materials_Name" />
                                            <ext:Column runat="server" Text="Đơn vị tính" Width="90" DataIndex="Unit_Name" />
                                            <ext:Column runat="server" Text="SL đề nghị" Width="90" DataIndex="Order_Detail_Quality">
                                                <Editor>
                                                    <ext:NumberField runat="server" MinValue="0">
                                                    </ext:NumberField>
                                                </Editor>
                                            </ext:Column>
                                            <ext:Column runat="server" AllowBlank="false" MinValue="0" Text="Đơn giá" Width="100" DataIndex="Order_Detail_Price">
                                                    <Editor>
                                                    <ext:NumberField runat="server" MinValue="0">
                                                    </ext:NumberField>
                                                </Editor>
                                                <Renderer Fn="Ext.util.Format.numberRenderer('0,000')" />
                                            </ext:Column>
                                            <ext:NumberColumn runat="server" Text="Tiền CK" Width="90" DataIndex="Order_Detail_CK" Format="0,00" />
                                            <ext:Column runat="server" Text="CK %" Width="90" DataIndex="Order_Detail_CK_Percent">
                                               <Editor>
                                                    <ext:NumberField runat="server" MinValue="0">
                                                    </ext:NumberField>
                                                </Editor>
                                            </ext:Column>
                                            <ext:NumberColumn runat="server" Text="Tiền VAT" Width="90" DataIndex="Order_Detail_VAT" Format="0,00" />
                                            <ext:Column runat="server" Text="VAT %" Width="90" DataIndex="Order_Detail_VAT_Percent">
                                                <Editor>
                                                    <ext:NumberField runat="server" MinValue="0">
                                                    </ext:NumberField>
                                                </Editor>
                                            </ext:Column>
                                            <ext:NumberColumn runat="server" Text="Thành tiền" Width="90" DataIndex="Order_Detail_Total_Price" Format="0,00" /> 
                                        </Columns>
                                    </ColumnModel>
                                    <Plugins>
                                        <ext:RowEditing runat="server" SaveBtnText="Cập nhật" CancelBtnText="Hủy bỏ">
                                            <DirectEvents>
                                                <Edit OnEvent="UpdateOrderReview_Click">
                                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                                    <ExtraParams>
                                                        <ext:Parameter Name="grOrderReview" Value="Ext.encode(#{grOrderReview}.getRowsValues({selectedOnly : true}))" Mode="Raw" />
                                                    </ExtraParams>
                                                </Edit>
                                            </DirectEvents>
                                        </ext:RowEditing>
                                    </Plugins>
                                    <SelectionModel>
                                        <ext:CheckboxSelectionModel runat="server" Mode="Multi" />
                                    </SelectionModel>
                                    <DockedItems>
                                        <ext:Toolbar runat="server" Dock="Bottom" AnchorHorizontal="100%">
                                            <Items>
                                                <ext:PagingToolbar runat="server" StoreID="StoreOrderReview" EmptyMsg="Không có dữ liệu" BeforePageText="Trang" AfterPageText="của {0}" LastText="Cuối" NextText="Kế tiếp" PrevText="Trở lại" FirstText="Đầu" RefreshText="Làm tươi" DisplayInfo="true" DisplayMsg="Trang {0} - {1} của {2}" />
                                            </Items>
                                        </ext:Toolbar>
                                    </DockedItems>
                                </ext:GridPanel>
                                </Items>
                            </ext:Panel>
                            <ext:Panel
                            runat="server" 
                            Width="736"
                            MarginSpec="5 0 0 0"
                            Border="True"
                            Frame="True"
                            Height="56">
                                <Items>
                                    <ext:FieldContainer
                                    runat="server"
                                    AnchorHorizontal="100%">
                                    <Items>
                                        <ext:Label runat="server" Text="Tổng tiền các mặt hàng bao gồm CK và VAT:" MarginSpec="0 8 8 0"></ext:Label>
                                        <ext:Label ID="lbTotalMaterialReview" Cls="x-label-right-cost" runat="server" Text="0"></ext:Label>
                                    </Items>
                                </ext:FieldContainer>
                                </Items>
                            </ext:Panel>
                        </Items>
                </ext:Panel>
            </Items>
        </ext:Window>
    </Content>
</ext:Panel>